package MazeGenProject;

import java.awt.Dimension;
import java.awt.Graphics;

import org.jhotdraw.standard.StandardDrawing;

public class GridDrawing extends StandardDrawing {
	
	private GridFigure[] _columns;
	private GridFigure[] _rows;
	private final int _space = 20;
	private final int _gridAdj = 550;
	
	public GridDrawing(Dimension d){
		Dimension dim = new Dimension(d.width + _gridAdj, d.height  + _gridAdj);
		_columns = new GridFigure[(int) Math.floor(dim.width /_space)];
		_rows = new GridFigure[(int) Math.floor(dim.height /_space)];
		createGridFigures();
	}
	
	public void createGridFigures(){
		int step = 0;
		for(int i=0; i<_columns.length; i++){
			GridFigure line = new GridFigure();
			line.startPoint(step, 0);
			line.endPoint(step, _columns.length*_space);
			_columns[i] = line;
			step = step + _space;
			this.add(line);
		}
		step = 0;
		for(int i=0; i<_rows.length; i++){
			GridFigure line = new GridFigure();
			line.startPoint(0, step);
			line.endPoint(_rows.length*_space, step);
			_rows[i] = line;
			step = step + _space;
			this.add(line);
		}
		
	}
	
	public GridFigure[] getGridColumns(){
		return _columns;
	}
	
	public GridFigure[] getGridRows(){
		return _rows;
	}
	
	public int getSpace(){
		return _space;
	}
	
	@Override
	public void draw(Graphics g) {
        draw(g, figures());
    }

}
